var template = {}
template.static={}
template.dynamic={}
template.dynamic.templateResolve = function (){
    $('#dynamic-template-ul .form-control').attr('type','number')
    $('#dynamic-template-ul .form-control').change(function (){
        template.dynamic.scoreCompute()
    })
}

template.dynamic.scoreCompute=function (){
    var question1_total_count = 0
    var question1_total_score = 0

    var question1_score = $('#dynamic-question1-score').val()
    var question1_simple_count = $('#dynamic-question1-simple-count').val()
    var question1_medium_count = $('#dynamic-question1-medium-count').val()
    var question1_difficult_count = $('#dynamic-question1-difficult-count').val()

    if (question1_score!='' && question1_simple_count!='' && question1_medium_count!='' && question1_difficult_count!=''){
        question1_total_score = (parseInt(question1_simple_count)+parseInt(question1_medium_count)+parseInt(question1_difficult_count))*parseInt(question1_score)
        question1_total_count = parseInt(question1_simple_count)+parseInt(question1_medium_count)+parseInt(question1_difficult_count)
        $('#dynamic-question1-total_count').html(question1_total_count+'题')
        $('#dynamic-question1-total_score').html(question1_total_score+'分')
    }

    var question2_total_count = 0
    var question2_total_score = 0

    var question2_score = $('#dynamic-question2-score').val()
    var question2_simple_count = $('#dynamic-question2-simple-count').val()
    var question2_medium_count = $('#dynamic-question2-medium-count').val()
    var question2_difficult_count = $('#dynamic-question2-difficult-count').val()

    if (question2_score!='' && question2_simple_count!='' && question2_medium_count!='' && question2_difficult_count!=''){
        question2_total_score = (parseInt(question2_simple_count)+parseInt(question2_medium_count)+parseInt(question2_difficult_count))*parseInt(question2_score)
        question2_total_count = parseInt(question2_simple_count)+parseInt(question2_medium_count)+parseInt(question2_difficult_count)
        $('#dynamic-question2-total_count').html(question2_total_count+'题')
        $('#dynamic-question2-total_score').html(question2_total_score+'分')
    }

    var question3_total_count = 0
    var question3_total_score = 0

    var question3_score = $('#dynamic-question3-score').val()
    var question3_simple_count = $('#dynamic-question3-simple-count').val()
    var question3_medium_count = $('#dynamic-question1-medium-count').val()
    var question3_difficult_count = $('#dynamic-question3-difficult-count').val()
    if (question3_score!='' && question3_simple_count!='' && question3_medium_count!='' && question3_difficult_count!=''){
        question3_total_score = (parseInt(question3_simple_count)+parseInt(question3_medium_count)+parseInt(question3_difficult_count))*parseInt(question3_score)
        question3_total_count = parseInt(question3_simple_count)+parseInt(question3_medium_count)+parseInt(question3_difficult_count)
        $('#dynamic-question3-total_count').html(question3_total_count+'题')
        $('#dynamic-question3-total_score').html(question3_total_score+'分')
    }


    var question4_total_count = 0
    var question4_total_score = 0

    var question4_score = $('#dynamic-question4-score').val()
    var question4_simple_count = $('#dynamic-question4-simple-count').val()
    var question4_medium_count = $('#dynamic-question4-medium-count').val()
    var question4_difficult_count = $('#dynamic-question4-difficult-count').val()
    if (question4_score!='' && question4_simple_count!='' && question4_medium_count!='' && question4_difficult_count!=''){
        question4_total_score = (parseInt(question4_simple_count)+parseInt(question4_medium_count)+parseInt(question4_difficult_count))*parseInt(question4_score)
        question4_total_count = parseInt(question4_simple_count)+parseInt(question4_medium_count)+parseInt(question4_difficult_count)
        $('#dynamic-question4-total_count').html(question4_total_count+'题')
        $('#dynamic-question4-total_score').html(question4_total_score+'分')
    }


    var question5_total_count = 0
    var question5_total_score = 0

    var question5_score = $('#dynamic-question5-score').val()
    var question5_simple_count = $('#dynamic-question5-simple-count').val()
    var question5_medium_count = $('#dynamic-question5-medium-count').val()
    var question5_difficult_count = $('#dynamic-question5-difficult-count').val()
    if (question5_score!='' && question5_simple_count!='' && question5_medium_count!='' && question5_difficult_count!=''){
        question5_total_score = (parseInt(question5_simple_count)+parseInt(question5_medium_count)+parseInt(question5_difficult_count))*parseInt(question5_score)
        question5_total_count = parseInt(question5_simple_count)+parseInt(question5_medium_count)+parseInt(question5_difficult_count)
        $('#dynamic-question5-total_count').html(question5_total_count+'题')
        $('#dynamic-question5-total_score').html(question5_total_score+'分')
    }
    $('#dynamic_template_total_score').val(
        question1_total_score+question2_total_score+question3_total_score+question4_total_score+question5_total_score
    )
}
template.dynamic.templateSave=function (){
    var param={
        name:$('#dynamic-name').val(),
        type:'动态模板',
        question1_score:$('#dynamic-question1-score').val(),
        question2_score:$('#dynamic-question2-score').val(),
        question3_score:$('#dynamic-question3-score').val(),
        question4_score:$('#dynamic-question4-score').val(),
        question5_score:$('#dynamic-question5-score').val(),
        question1_simple_count:$('#dynamic-question1-simple-count').val(),
        question1_medium_count:$('#dynamic-question1-medium-count').val(),
        question1_difficult_count:$('#dynamic-question1-difficult-count').val(),

        question2_simple_count:$('#dynamic-question2-simple-count').val(),
        question2_medium_count:$('#dynamic-question2-medium-count').val(),
        question2_difficult_count:$('#dynamic-question2-difficult-count').val(),

        question3_simple_count:$('#dynamic-question3-simple-count').val(),
        question3_medium_count:$('#dynamic-question3-medium-count').val(),
        question3_difficult_count:$('#dynamic-question3-difficult-count').val(),

        question4_simple_count:$('#dynamic-question4-simple-count').val(),
        question4_medium_count:$('#dynamic-question4-medium-count').val(),
        question4_difficult_count:$('#dynamic-question4-difficult-count').val(),

        question5_simple_count:$('#dynamic-question5-simple-count').val(),
        question5_medium_count:$('#dynamic-question5-medium-count').val(),
        question5_difficult_count:$('#dynamic-question5-difficult-count').val(),

        question_total_score:$('#dynamic_template_total_score').val(),
        course:$('#dynamic-course').val()
    }
    var savePath = ''
    var editID = $('#editTemplateId').val()
    if (editID!=null && editID!=''){
        param.id = editID
    }
    $.post('template/dynamic/save',param,function (f){
        if (f){
            alert('保存成功')
            template.dynamic.clearTemplate()
            mainNavigation.templateList()
        }else {
            alert('模板名称重复')
        }
    })
}
template.dynamic.clearTemplate=function (){
    // 清空模板头部
    $('#dynamic-name').val('')
    $('#dynamic-course').val('')
    $('#dynamic_template_total_score').val(0)

    //清空单选题
    $('#dynamic-question1-total_count').html('0题')
    $('#dynamic-question1-total_score').html('0分')
    $('#dynamic-question1-score').val(0)
    $('#dynamic-question1-simple-count').val(0)
    $('#dynamic-question1-medium-count').val(0)
    $('#dynamic-question1-difficult-count').val(0)
    //清空多选题
    $('#dynamic-question2-total_count').html('0题')
    $('#dynamic-question2-total_score').html('0分')
    $('#dynamic-question2-score').val(0)
    $('#dynamic-question2-simple-count').val(0)
    $('#dynamic-question2-medium-count').val(0)
    $('#dynamic-question2-difficult-count').val(0)
    //清空判断题
    $('#dynamic-question3-total_count').html('0题')
    $('#dynamic-question3-total_score').html('0分')
    $('#dynamic-question3-score').val(0)
    $('#dynamic-question3-simple-count').val(0)
    $('#dynamic-question3-medium-count').val(0)
    $('#dynamic-question3-difficult-count').val(0)
    //清空填空题
    $('#dynamic-question4-total_count').html('0题')
    $('#dynamic-question4-total_score').html('0分')
    $('#dynamic-question4-score').val(0)
    $('#dynamic-question4-simple-count').val(0)
    $('#dynamic-question4-medium-count').val(0)
    $('#dynamic-question4-difficult-count').val(0)
    //清空综合题
    $('#dynamic-question5-total_count').html('0题')
    $('#dynamic-question5-total_score').html('0分')
    $('#dynamic-question5-score').val(0)
    $('#dynamic-question5-simple-count').val(0)
    $('#dynamic-question5-medium-count').val(0)
    $('#dynamic-question5-difficult-count').val(0)
}
var E = window.wangEditor
var separator = '}-|-{'
var staticQuestionHeadEditor//题干编辑器
var currentQuestionEditor//存储的是当前modal的其他编辑器对象
template.static.computeRightScore=function (){
//首先获取模板中的试题  获取每种题型的个数
    var static_template_question1_count = 0;
    var static_template_question2_count = 0;
    var static_template_question3_count = 0;
    var static_template_question4_count = 0;
    var static_template_question5_count = 0;
    var static_template_question4_blank_count = 0;
    $('#static_template_box #static_template_left_part #static_template_left_content_box #static_template_left_content_box_inner_content div .static_template_left_content .static_template_left_content_head span').each(function (i,span){
        if (span.innerText.indexOf('单选题')!=-1){
            static_template_question1_count++
        }else if (span.innerText.indexOf('多选题')!=-1){
            static_template_question2_count++
        }else if (span.innerText.indexOf('判断题')!=-1){
            static_template_question3_count++
        }else if (span.innerText.indexOf('填空题')!=-1){
            $(span).parent().next().children('div').each(function (i,div){
                static_template_question4_blank_count ++
            })
            static_template_question4_blank_count = static_template_question4_blank_count -1
            static_template_question4_count++
        }else if (span.innerText.indexOf('综合题')!=-1){
            static_template_question5_count++
        }
    })

    // console.log(static_template_question1_count+'-'+static_template_question2_count+'-'+static_template_question3_count+'-'+static_template_question4_count+'-'+static_template_question5_count)
    //获取静态模板右侧的分值
    var static_template_question1_score = $('#static_template_box #static_template_right_part #static_template_question1 #static_template_question1_content .param_input_group input').val()
    var static_template_question2_score = $('#static_template_box #static_template_right_part #static_template_question2 #static_template_question2_content .param_input_group input').val()
    var static_template_question3_score = $('#static_template_box #static_template_right_part #static_template_question3 #static_template_question3_content .param_input_group input').val()
    var static_template_question4_score = $('#static_template_box #static_template_right_part #static_template_question4 #static_template_question4_content .param_input_group input').val()
    var static_template_question5_score = $('#static_template_box #static_template_right_part #static_template_question5 #static_template_question5_content .param_input_group input').val()
    // console.log(static_template_question1_score+'-'+static_template_question2_score+'-'+static_template_question3_score+'-'+static_template_question4_score+'-'+static_template_question5_score)
    var static_template_question1_total_score = static_template_question1_count * static_template_question1_score;
    var static_template_question2_total_score = static_template_question2_count * static_template_question2_score;
    var static_template_question3_total_score = static_template_question3_count * static_template_question3_score;
    var static_template_question4_total_score = static_template_question4_blank_count * static_template_question4_score;
    var static_template_question5_total_score = static_template_question5_count * static_template_question5_score;
    var static_template_question_total_score = static_template_question1_total_score + static_template_question2_total_score + static_template_question3_total_score + static_template_question4_total_score + static_template_question5_total_score ;
    //将值拼接在静态模板右侧
    $('#static_template_box #static_template_right_part #static_template_total_score span:eq(1)').text(static_template_question_total_score+'分')
    $('#static_template_box #static_template_right_part #static_template_question1 #static_template_question1_content .param_input_group .param span:eq(0)').text(static_template_question1_count+'题')
    $('#static_template_box #static_template_right_part #static_template_question1 #static_template_question1_content .param_input_group .param span:eq(1)').text(static_template_question1_total_score+'分')
    $('#static_template_box #static_template_right_part #static_template_question2 #static_template_question2_content .param_input_group .param span:eq(0)').text(static_template_question2_count+'题')
    $('#static_template_box #static_template_right_part #static_template_question2 #static_template_question2_content .param_input_group .param span:eq(1)').text(static_template_question2_total_score+'分')
    $('#static_template_box #static_template_right_part #static_template_question3 #static_template_question3_content .param_input_group .param span:eq(0)').text(static_template_question3_count+'题')
    $('#static_template_box #static_template_right_part #static_template_question3 #static_template_question3_content .param_input_group .param span:eq(1)').text(static_template_question3_total_score+'分')
    $('#static_template_box #static_template_right_part #static_template_question4 #static_template_question4_content .param_input_group .param span:eq(0)').text(static_template_question4_count+'题')
    $('#static_template_box #static_template_right_part #static_template_question4 #static_template_question4_content .param_input_group .param span:eq(1)').text(static_template_question4_blank_count+'空')
    $('#static_template_box #static_template_right_part #static_template_question4 #static_template_question4_content .param_input_group .param span:eq(2)').text(static_template_question4_total_score+'分')
    $('#static_template_box #static_template_right_part #static_template_question5 #static_template_question5_content .param_input_group .param span:eq(0)').text(static_template_question5_count+'题')
    $('#static_template_box #static_template_right_part #static_template_question5 #static_template_question5_content .param_input_group .param span:eq(1)').text(static_template_question5_total_score+'分')
}
template.static.addQuestion=function (){
    $.post('template/static/addQuestion.html',null,function (view){
        $('#common-modal .modal-dialog').addClass('modal-lg')
        common.commonModalDialogClearSubmitButtonBind()
        common.commonModalDialog('添加试题',view,function (){
            template.static.question_submit()
        })
        staticQuestionHeadEditor = new E('#static-template-question-head')
        staticQuestionHeadEditor.config.height=200
        staticQuestionHeadEditor.create()
        template.static.default_question_template()
    })
}
template.static.question_submit=function (){
    //需要添加一个参数  因为编辑模板中添加试题需要添加到一个新的session中 需要一个模板id
    var editTemplateId = $('#static_template_box #static_template_top_part .form-inline #static_template_id').val()
    var questionParam = {
        editTemplateId:editTemplateId!=null?editTemplateId:'',
        type:$('#static_template_add_form .form-group #static-template-question-type').val(),
        course:'',
        level:$('#static_template_add_form .form-group #static-template-question-level').val(),
        subject:staticQuestionHeadEditor.txt.text(),
        options:'',
        answer:'',
        status:'',
    }
    var tempOptions = ''
    var tempAnswers = ''
    if (questionParam.type=='单选题' || questionParam.type=='多选题'){
        // 需要获取每个选项的editor  这个在这里获取不到
        for (var i = 0;i<currentQuestionEditor.length;i++){
            tempOptions = tempOptions +currentQuestionEditor[i].txt.text()+separator
        }
        $('#static_template_add_form #static_template_question_content_box .form-group input:checked').each(function (i,element){
            tempAnswers = tempAnswers +element.value+separator
        })
        questionParam.options = tempOptions
        questionParam.answer = tempAnswers

    }
    if (questionParam.type=='判断题'){
        $('#static_template_add_form #static_template_question_content_box .form-group #static_template_question3_answer span b').each(function (i,element){
            tempOptions = tempOptions + element.innerText +separator
        })
        tempAnswers = $('#static_template_add_form #static_template_question_content_box .form-group #static_template_question3_answer span input:checked').val()
        questionParam.options = tempOptions
        questionParam.answer = tempAnswers
    }
    if (questionParam.type=='填空题'){
        $('#static_template_add_form #static_template_question_content_box .form-group .static_template_question4  input').each(function (i,element){
            tempAnswers = tempAnswers + element.value + separator
            questionParam.answer = tempAnswers
        })
        questionParam.options = '无'
    }
    if (questionParam.type=='综合题'){
        tempAnswers = currentQuestionEditor[0].txt.text()
        questionParam.answer = tempAnswers
        questionParam.options = '无'
    }
    if (questionParam.subject=='' || questionParam.options=='' || questionParam.answer==''){
        alert('请将内容填写完毕！！！')
        return
    }
    //发送请求后端保存
    $.post('template/static/questionSave.html',questionParam,function (view){
        alert('添加成功')
        common.commonModalDialogClose()
        //单独写一个添加完后  对分数的处理
        if (editTemplateId!=null&&editTemplateId!=''){
            $('.context').html(view)
            template.dynamic.templateResolve()
            template.static.computeRightScore()
        }else {
            $('#static_template_box #static_template_left_part #static_template_left_content_box #static_template_left_bottom_button_group').before(view)
            mainNavigation.addTemplateNavigation()
        }

    })

}
template.static.addQuestionSelect=function (index){
    if (index == 1){
        $('#static_template_add_form #static_template_question_content_box #static_template_addQuestionSelectButton').before(' <div class="form-group row">\n' +
            '                    <label class="col-md-2 control-label"><input name="select" type="radio"/><b></b>选项</label>\n' +
            '                    <div class="col-md-8">\n' +
            '                        <div class="static_template_question'+index+'_content_editor"></div>\n' +
            '                    </div>\n' +
            '                    <div class="col-md-2">\n' +
            '                        <button onclick="template.static.deleteQuestionSelect(this)" type="button" class="btn-danger btn-lg"><label class="glyphicon glyphicon-minus"></label></button>\n' +
            '                    </div>\n' +
            '                </div>')
    }else if (index == 2){
        $('#static_template_add_form #static_template_question_content_box #static_template_addQuestionSelectButton').before(' <div class="form-group row">\n' +
            '                    <label class="col-md-2 control-label"><input name="select" type="checkbox"/><b></b>选项</label>\n' +
            '                    <div class="col-md-8">\n' +
            '                        <div class="static_template_question'+index+'_content_editor"></div>\n' +
            '                    </div>\n' +
            '                    <div class="col-md-2">\n' +
            '                        <button onclick="template.static.deleteQuestionSelect(this)" type="button" class="btn-danger btn-lg"><label class="glyphicon glyphicon-minus"></label></button>\n' +
            '                    </div>\n' +
            '                </div>')
    }

    template.static.lastQuestionSelectEditorManage(index)
    template.static.lastQuestionSelectEditorRank()
}
template.static.deleteQuestionSelect=function (self){
    if (!confirm('是否确认删除')){
        return;
    }
    var questions = $('#static_template_add_form #static_template_question_content_box .form-group')
    if (questions.length<=2){
        alert('至少保证存在两个选项')
        return;
    }
    $(self).parent().parent().remove()
    template.static.allQuestionSelectSort()
}
template.static.allQuestionSelectSort=function (){
    $('#static_template_add_form #static_template_question_content_box .form-group b').each(function (i,element){
        element.innerText = String.fromCharCode('A'.charCodeAt(0)+i)
    })

}
template.static.clearQuestionContent=function (){
    $('#static_template_add_form #static_template_question_content_box').html('')
}
template.static.lastQuestionSelectEditorRank=function (){
    var tempInput = $('#static_template_add_form #static_template_question_content_box .form-group label input')
    tempInput[tempInput.length-1].value=String.fromCharCode('A'.charCodeAt(0)+tempInput.length-1)
    var tempB = $('#static_template_add_form #static_template_question_content_box .form-group b')
    tempB[tempB.length-1].innerText=String.fromCharCode('A'.charCodeAt(0)+tempB.length-1)

}
template.static.lastQuestionSelectEditorManage=function (index){
    var editors = $('#static_template_add_form #static_template_question_content_box .static_template_question'+index+'_content_editor')
    var editorLength = editors.length
    var tempEditor = new E(editors[editorLength-1])
    tempEditor.config.height=200
    tempEditor.create()
    currentQuestionEditor[editorLength - 1] = tempEditor
}
template.static.question4_listener=function (){
    staticQuestionHeadEditor.txt.eventHooks.changeEvents.push(function (){
        var content = staticQuestionHeadEditor.txt.html()
        var index = content.indexOf('【】')
        var blankCount = 0
        while(true){
            if (index!=-1){
                blankCount++
                content = content.substring(index+2)
                index = content.indexOf('【】')
                continue
            }
            break
        }
        $('#static_template_add_form #static_template_question_content_box').html('')
        for (var i = 0;i<blankCount;i++){
            $('#static_template_add_form #static_template_question_content_box').append(' <div class="form-group">\n' +
                '                    <label class="col-md-2 control-label">填空<b>'+(i+1)+'</b></label>\n' +
                '                    <div class="static_template_question4 col-md-8">\n' +
                '                        <input type="text"/>\n' +
                '                    </div>\n' +
                '                </div>')
        }
    })
}
template.static.question4_button_add=function (){

    var { $, BtnMenu, DropListMenu, PanelMenu, DropList, Panel, Tooltip } = E
    // 第一，菜单 class ，Button 菜单继承 BtnMenu class
    class BlankMenu extends BtnMenu {
        constructor(staticQuestionHeadEditor) {
            // data-title属性表示当鼠标悬停在该按钮上时提示该按钮的功能简述
            var $elem = E.$(
                `<div class="w-e-menu" data-title="添加一个填空区域">
                <i>Blank</i>
            </div>`
            )
            super($elem, staticQuestionHeadEditor)
        }
        // 菜单点击事件
        clickHandler() {
            // 做任何你想做的事情
            // 可参考【常用 API】文档，来操作编辑器
            staticQuestionHeadEditor.txt.append('<span>【】</span>')

        }
        // 菜单是否被激活（如果不需要，这个函数可以空着）
        // 1. 激活是什么？光标放在一段加粗、下划线的文本时，菜单栏里的 B 和 U 被激活，如下图
        // 2. 什么时候执行这个函数？每次编辑器区域的选区变化（如鼠标操作、键盘操作等），都会触发各个菜单的 tryChangeActive 函数，重新计算菜单的激活状态
        tryChangeActive() {
            // 激活菜单
            // 1. 菜单 DOM 节点会增加一个 .w-e-active 的 css class
            // 2. this.this.isActive === true
            this.active()

            // // 取消激活菜单
            // // 1. 菜单 DOM 节点会删掉 .w-e-active
            // // 2. this.this.isActive === false
            // this.unActive()
        }
    }
    var blankMenu = 'blankMenu'
    staticQuestionHeadEditor.destroy()
    staticQuestionHeadEditor = new E('#static-template-question-head')
    staticQuestionHeadEditor.config.height=200
    staticQuestionHeadEditor.menus.extend(blankMenu, BlankMenu)
    staticQuestionHeadEditor.config.menus = staticQuestionHeadEditor.config.menus.concat(blankMenu)
    staticQuestionHeadEditor.create()

}
template.static.clearQuestionEditorHead=function (){
    staticQuestionHeadEditor.destroy()
    staticQuestionHeadEditor = new E('#static-template-question-head')
    staticQuestionHeadEditor.config.height=200
    staticQuestionHeadEditor.create()
}

template.static.default_question_template=function (){//默认展示单选题的模板
    template.static.clearQuestionEditorHead()
    for (var i = 0 ;i<4;i++){
        $('#static_template_add_form #static_template_question_content_box').prepend(' <div class="form-group row">\n' +
            '                    <label class="col-md-2 control-label"><input name="select" type="radio"/><b></b>选项</label>\n' +
            '                    <div class="col-md-8">\n' +
            '                        <div class="static_template_question1_content_editor"></div>\n' +
            '                    </div>\n' +
            '                    <div class="col-md-2">\n' +
            '                        <button onclick="template.static.deleteQuestionSelect(this)" type="button" class="btn-danger btn-lg"><label class="glyphicon glyphicon-minus"></label></button>\n' +
            '                    </div>\n' +
            '                </div>')
    }
    $('#static_template_add_form #static_template_question_content_box').append('' +
        '<div id="static_template_addQuestionSelectButton" style="text-align: center">\n' +
        '                    <button onclick="template.static.addQuestionSelect(1)" type="button" class="btn btn-info"><label class="glyphicon glyphicon-plus"></label>增加选项</button>\n' +
        '                </div>')
    $('#static_template_add_form #static_template_question_content_box b').each(function (i,element){
        element.innerText=String.fromCharCode('A'.charCodeAt(0)+i)
    })
    $('#static_template_add_form #static_template_question_content_box input').each(function (i,element){
        element.value=String.fromCharCode('A'.charCodeAt(0)+i)
    })
    currentQuestionEditor = []
    $('#static_template_add_form #static_template_question_content_box .static_template_question1_content_editor').each(function (i,element){
        var temp = new E(element)
        temp.config.height=200
        temp.create()
        currentQuestionEditor[i] = temp
    })
}
template.static.question2_template=function (){//默认展示单选题的模板
    template.static.clearQuestionEditorHead()
    for (var i = 0 ;i<4;i++){
        $('#static_template_add_form #static_template_question_content_box').prepend(' <div class="form-group row">\n' +
            '                    <label class="col-md-2 control-label"><input type="checkbox"/><b></b>选项</label>\n' +
            '                    <div class="col-md-8">\n' +
            '                        <div class="static_template_question2_content_editor"></div>\n' +
            '                    </div>\n' +
            '                    <div class="col-md-2">\n' +
            '                        <button onclick="template.static.deleteQuestionSelect(this)" type="button" class="btn-danger btn-lg"><label class="glyphicon glyphicon-minus"></label></button>\n' +
            '                    </div>\n' +
            '                </div>')
    }
    $('#static_template_add_form #static_template_question_content_box').append('' +
        '<div id="static_template_addQuestionSelectButton" style="text-align: center">\n' +
        '                    <button onclick="template.static.addQuestionSelect(2)" type="button" class="btn btn-info"><label class="glyphicon glyphicon-plus"></label>增加选项</button>\n' +
        '                </div>')
    $('#static_template_add_form #static_template_question_content_box b').each(function (i,element){
        element.innerText=String.fromCharCode('A'.charCodeAt(0)+i)
    })
    $('#static_template_add_form #static_template_question_content_box input').each(function (i,element){
        element.value=String.fromCharCode('A'.charCodeAt(0)+i)
    })
    currentQuestionEditor = []
    $('#static_template_add_form #static_template_question_content_box .static_template_question2_content_editor').each(function (i,element){
        var temp = new E(element)
        temp.config.height=200
        temp.create()
        currentQuestionEditor[i] = temp
    })
}
template.static.question3_template=function (){
    template.static.clearQuestionEditorHead()
    $('#static_template_add_form #static_template_question_content_box').append('  <div class="form-group row">\n' +
        '                    <label class="col-md-2 control-label" for="static_template_question3_answer">试题答案</label>\n' +
        '                    <div style="padding-bottom: 0px" id="static_template_question3_answer" class="col-md-8">\n' +
        '                        <span>\n' +
        '                            <input type="radio" value="正确" name="question3"/><b class="glyphicon glyphicon-ok">正确</b>\n' +
        '                        </span>\n' +
        '                        <span>\n' +
        '                            <input type="radio" value="错误" name="question3"/><b class="glyphicon glyphicon-remove">错误</b>\n' +
        '                        </span>\n' +
        '                    </div>\n' +
        '                </div>')
}
// template.static.question4_template=function (){    用不上
//     template.static.clearQuestionEditorHead()
// }
template.static.question5_template=function (){
    template.static.clearQuestionEditorHead()
    $('#static_template_add_form #static_template_question_content_box').append(' <div class="form-group row">\n' +
        '                    <label class="col-md-2 control-label">试题答案</label>\n' +
        '                    <div class="col-md-8">\n' +
        '                        <div id="static_template_question5_answer"></div>\n' +
        '                    </div>\n' +
        '                </div>')
    var templateEditor = new E('#static_template_question5_answer')
    templateEditor.config.height=200
    templateEditor.create()
    currentQuestionEditor = []
    currentQuestionEditor[0] = templateEditor
}

template.static.changeQuestionType=function (){
    var questionType= $('#static_template_add_form .form-group #static-template-question-type').val()
    if (questionType=='单选题'){
        template.static.clearQuestionContent()
        template.static.default_question_template()
    }
    if (questionType=='多选题'){
        template.static.clearQuestionContent()
        template.static.question2_template()
    }
    if (questionType=='填空题'){
        template.static.clearQuestionContent()
        //给题干编辑器添加一个按钮
        template.static.question4_button_add()
        //添加钩子时间
        template.static.question4_listener()
    }
    if (questionType=='判断题'){
        template.static.clearQuestionContent()
        template.static.question3_template()

    }
    if (questionType=='综合题'){
        template.static.clearQuestionContent()
        template.static.question5_template()
    }
}


template.static.changeScore=function () {
    template.static.computeRightScore()
}
template.static.question_delete=function (a){
    var removeIndex = $(a).parent().next('.static_template_left_content_head').find('input').val()
    $(a).parent().parent().parent().remove()
    template.static.question_sort()
    template.static.computeRightScore()
    $.post('template/deleteQuestion',{index:removeIndex,editTemplateId:$('#static_template_id').val()},function (){
        alert('删除成功')
    })
}
template.static.question_sort=function (){
    //上面也有一个allQuestionSelectSort()  也是排序 但是忘了排什么的  这里再写一个
    //这个是对静态模板中所有缓存的试题的排序   这里因为对jquery理解不深  所以  写了两个each  性能会差
    $('#static_template_box #static_template_left_part #static_template_left_content_box #static_template_left_content_box_inner_content div .static_template_left_content .static_template_left_content_head input').each(function (i,element){
         element.value = i +1
    })
    $('#static_template_box #static_template_left_part #static_template_left_content_box #static_template_left_content_box_inner_content div .static_template_left_content .static_template_left_content_head span').each(function (i,element){
        element.innerText = (i+1)+'.'+element.innerText.substring(element.innerText.indexOf('.')+1)
    })
}
template.static.selectAllQuestion=function (input){
    var status = $(input).prop('checked')
    $('#static_template_box #static_template_left_part #static_template_left_content_box #static_template_left_content_box_inner_content div .static_template_left_content .static_template_left_content_head :checkbox').prop('checked',status)
}
template.static.deleteMoreQuestion=function (){
    var questionLength = $('#static_template_box #static_template_left_part #static_template_left_content_box #static_template_left_content_box_inner_content div .static_template_left_content .static_template_left_content_head :checked').length
    if (questionLength<=0){
        alert('请至少选择一个想要删除的选项')
        return;
    }

    var deleteQuestionNumbers = ''
    $('#static_template_box #static_template_left_part #static_template_left_content_box #static_template_left_content_box_inner_content div .static_template_left_content .static_template_left_content_head :checked').each(function (i,element){
        $(element).parent().parent().parent().remove()
        deleteQuestionNumbers += element.value + ','
    })
    template.static.question_sort()
    template.static.computeRightScore()
    $.post('template/deleteMoreQuestion',{questionNumbers:deleteQuestionNumbers},function (){
        alert('删除成功')
    })
}
template.static.questionEdit=function (edit){
    var questionNumber = $(edit).parent().next('.static_template_left_content_head').children('input').val()
    $.post('template/static/selectQuestion',{number:questionNumber},function (questionVO){
        var type = questionVO.type
        var number = questionNumber
        var content = questionVO.subject
        var level = questionVO.level
        // console.log(level)
        switch (type){
            case '单选题' : template.static.question1_edit(number,type,content,level,questionVO);break;
            case '多选题' : template.static.question2_edit(number,type,content,level,questionVO);break;
            case '判断题' : template.static.question3_edit(number,type,content,level,questionVO);break;
            case '填空题' : template.static.question4_edit(number,type,content,level,questionVO);break;
            case '综合题' : template.static.question5_edit(number,type,content,level,questionVO);break;
        }
    })

}
template.static.question1_edit=function (number,type,content,level,questionVO){
    $.post('template/static/addQuestion.html',null,function (view){
        $('#common-modal .modal-dialog').addClass('modal-lg')
        common.commonModalDialogClearSubmitButtonBind()

        common.commonModalDialog('编辑试题',view,function (){
            var edit_after_number = number
            var edit_after_level = $('#static_template_add_form .form-group:eq(0) .col-md-8 #static-template-question-level').val()
            var edit_after_type = $('#static_template_add_form .form-group:eq(1) .col-md-8 #static-template-question-type').val()
            var edit_after_content = staticQuestionHeadEditor.txt.text()
            var edit_after_answer = $('#static_template_add_form #static_template_question_content_box .form-group .control-label input:checked').val()
            var edit_after_options = ''
            for (var i = 0;i<currentQuestionEditor.length;i++){
                edit_after_options += currentQuestionEditor[i].txt.text() + separator
            }
            // console.log(edit_after_number+'---'+edit_after_level+'---'+edit_after_type+'---'+edit_after_content+'---'+edit_after_answer+'------'+edit_after_options)
            template.static.question_edit_save(edit_after_number,edit_after_level,edit_after_type,edit_after_content,edit_after_answer,edit_after_options)
        })
        staticQuestionHeadEditor = new E('#static-template-question-head')
        staticQuestionHeadEditor.config.height=200
        staticQuestionHeadEditor.create()
        template.static.default_question_template()

        //拼接原数据
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').val(type)
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').attr('disabled',true)
        $('#static_template_add_form .form-group:eq(0) #static-template-question-level').val(level)
        staticQuestionHeadEditor.txt.text(content)
        //选项的拼接
        $('#static_template_add_form #static_template_question_content_box .form-group .control-label input').each(function (i,input){
            if (questionVO.answers[i]!=null && input.value == questionVO.answers[i]){
                $(input).attr('checked',true)
            }
            currentQuestionEditor[i].txt.text(questionVO.options[i])
        })


    })
}
template.static.question2_edit=function (number,type,content,level,questionVO){
    $.post('template/static/addQuestion.html',null,function (view){
        $('#common-modal .modal-dialog').addClass('modal-lg')
        common.commonModalDialogClearSubmitButtonBind()

        common.commonModalDialog('编辑试题',view,function (){
            var edit_after_number = number
            var edit_after_level = $('#static_template_add_form .form-group:eq(0) .col-md-8 #static-template-question-level').val()
            var edit_after_type = $('#static_template_add_form .form-group:eq(1) .col-md-8 #static-template-question-type').val()
            var edit_after_content = staticQuestionHeadEditor.txt.text()
            var edit_after_answer = ''
            $('#static_template_add_form #static_template_question_content_box .form-group .control-label input:checked').each(function (i,input){
                edit_after_answer += input.value +separator
            })
            var edit_after_options = ''
            for (var i = 0;i<currentQuestionEditor.length;i++){
                edit_after_options += currentQuestionEditor[i].txt.text() + separator
            }
            // console.log(edit_after_number+'---'+edit_after_level+'---'+edit_after_type+'---'+edit_after_content+'---'+edit_after_answer+'------'+edit_after_options)
            template.static.question_edit_save(edit_after_number,edit_after_level,edit_after_type,edit_after_content,edit_after_answer,edit_after_options)
        })
        staticQuestionHeadEditor = new E('#static-template-question-head')
        staticQuestionHeadEditor.config.height=200
        staticQuestionHeadEditor.create()
        template.static.question2_template()

        //拼接原数据
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').val(type)
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').attr('disabled',true)
        $('#static_template_add_form .form-group:eq(0) #static-template-question-level').val(level)
        staticQuestionHeadEditor.txt.text(content)
        //选项的拼接
        $('#static_template_add_form #static_template_question_content_box .form-group .control-label input').each(function (i,input){
            if (questionVO.answers[i]!=null && input.value == questionVO.answers[i]){
                $(input).attr('checked',true)
            }
            currentQuestionEditor[i].txt.text(questionVO.options[i])
        })


    })
}
template.static.question3_edit=function (number,type,content,level,questionVO){
    $.post('template/static/addQuestion.html',null,function (view){
        $('#common-modal .modal-dialog').addClass('modal-lg')
        common.commonModalDialogClearSubmitButtonBind()

        common.commonModalDialog('编辑试题',view,function (){
            var edit_after_number = number
            var edit_after_level = $('#static_template_add_form .form-group:eq(0) .col-md-8 #static-template-question-level').val()
            var edit_after_type = $('#static_template_add_form .form-group:eq(1) .col-md-8 #static-template-question-type').val()
            var edit_after_content = staticQuestionHeadEditor.txt.text()
            var edit_after_answer = $('#static_template_add_form #static_template_question_content_box .form-group #static_template_question3_answer span input:checked').val()
            // console.log(edit_after_number+'---'+edit_after_level+'---'+edit_after_type+'---'+edit_after_content+'---'+edit_after_answer)
            template.static.question_edit_save(edit_after_number,edit_after_level,edit_after_type,edit_after_content,edit_after_answer,'正确'+separator+'错误'+separator)
        })
        staticQuestionHeadEditor = new E('#static-template-question-head')
        staticQuestionHeadEditor.config.height=200
        staticQuestionHeadEditor.create()
        template.static.question3_template()

        //拼接原数据
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').val(type)
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').attr('disabled',true)
        $('#static_template_add_form .form-group:eq(0) #static-template-question-level').val(level)
        staticQuestionHeadEditor.txt.text(content)
        var question3_answer = questionVO.answers[0]
        $('#static_template_add_form #static_template_question_content_box #static_template_question3_answer span input').each(function (i,input){
            if (input.value == question3_answer){
                $(input).attr('checked',true)
            }
        })

    })

}
template.static.question4_edit=function (number,type,content,level,questionVO){
    $.post('template/static/addQuestion.html',null,function (view){
        $('#common-modal .modal-dialog').addClass('modal-lg')
        common.commonModalDialogClearSubmitButtonBind()
        common.commonModalDialog('编辑试题',view,function (){
            var edit_after_number = number
            var edit_after_level = $('#static_template_add_form .form-group:eq(0) .col-md-8 #static-template-question-level').val()
            var edit_after_type = $('#static_template_add_form .form-group:eq(1) .col-md-8 #static-template-question-type').val()
            var edit_after_content = staticQuestionHeadEditor.txt.text()
            var edit_after_answer = ''
            $('#static_template_add_form #static_template_question_content_box .static_template_question4  input').each(function (i,input){
                edit_after_answer += input.value + separator
            })
            // console.log(edit_after_number+'---'+edit_after_level+'---'+edit_after_type+'---'+edit_after_content+'---'+edit_after_answer)
            template.static.question_edit_save(edit_after_number,edit_after_level,edit_after_type,edit_after_content,edit_after_answer,'无')
        })
        staticQuestionHeadEditor = new E('#static-template-question-head')
        staticQuestionHeadEditor.config.height=200
        staticQuestionHeadEditor.create()
        //给题干编辑器添加一个按钮
        template.static.question4_button_add()
        //添加钩子时间  因为这个事件的问题 所以在编辑的时候  如果修改了文本内容就会出现 答案清空的现象  需要重新填写答案   我不想再这里细致处理了  老师的就没有问题
        template.static.question4_listener()
        //拼接原数据
        staticQuestionHeadEditor.txt.text(content)
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').val(type)
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').attr('disabled',true)
        $('#static_template_add_form .form-group:eq(0) #static-template-question-level').val(level)

        //将数据循环拼接
        var time = window.setTimeout(function (){
            var input = $('#static_template_add_form #static_template_question_content_box .static_template_question4  input')
            while(input.length == questionVO.answers.length){
                //说明input已经加载出来了
                for (var i = 0 ;i<questionVO.answers.length;i++){
                    input[i].value = questionVO.answers[i]
                }
                break;
            }
        },50)
    })
}
template.static.question5_edit=function (number,type,content,level,questionVO){
    $.post('template/static/addQuestion.html',null,function (view){
        $('#common-modal .modal-dialog').addClass('modal-lg')
        common.commonModalDialogClearSubmitButtonBind()
        common.commonModalDialog('编辑试题',view,function (){
            var edit_after_number = number
            var edit_after_level = $('#static_template_add_form .form-group:eq(0) .col-md-8 #static-template-question-level').val()
            var edit_after_type = $('#static_template_add_form .form-group:eq(1) .col-md-8 #static-template-question-type').val()
            var edit_after_content = staticQuestionHeadEditor.txt.text()
            var edit_after_answer = currentQuestionEditor[0].txt.text()
            // console.log(edit_after_number+'---'+edit_after_level+'---'+edit_after_type+'---'+edit_after_content+'---'+edit_after_answer)
            template.static.question_edit_save(edit_after_number,edit_after_level,edit_after_type,edit_after_content,edit_after_answer,'无')
        })
        staticQuestionHeadEditor = new E('#static-template-question-head')
        staticQuestionHeadEditor.config.height=200
        staticQuestionHeadEditor.create()
        template.static.question5_template()
        //拼接原数据
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').val(type)
        $('#static_template_add_form .form-group:eq(1) #static-template-question-type').attr('disabled',true)
        $('#static_template_add_form .form-group:eq(0) #static-template-question-level').val(level)
        staticQuestionHeadEditor.txt.text(content)
        currentQuestionEditor[0].txt.text(questionVO.answers[0])
    })
}

template.static.question_edit_save=function (number,level,type,content,answer,options){
    var question = {
        number:number,
        level:level,
        type:type,
        content:content,
        answer:answer,
        options:options
    }
    $.post('template/static/editSav',question,function (){
        alert('修改成功')
        common.commonModalDialogClose()
        mainNavigation.addTemplateNavigation()
    })
}

template.static.importQuestion=function (){
    $.post('template/staticFileUploadTemplate.html',null,function (view){
        common.commonModalDialogClearSubmitButtonBind()
        common.commonModalDialog('导入考题',view,function (){
                var files = $('#template-static-select-file').prop('files');//表示input中有一个files的属性 存储这我们的文件
                var data = new FormData();
                data.append('file', files[0]);
                var editTemplateId = $('#static_template_id').val();
                data.append("editTemplateId",editTemplateId!=null?editTemplateId:'')
                $.ajax({
                    url:'template/importQuestionSubmit',
                    data:data,
                    type:'POST',
                    cache:false,
                    processData:false,
                    contentType:false,
                    dataType:false,
                    success:function (view){
                        common.commonModalDialogClose()
                        if (editTemplateId!=null){
                            $('.context').html(view)
                            alert($('#static_template_import_result').val())
                        }else {
                            $('#static_template_left_part #static_template_left_content_box #static_template_left_bottom_button_group').before(' <div  id="static_template_left_content_box_inner_content">'+view+'</div>')
                            alert($('#static_template_import_result').val())
                        }
                        template.static.computeRightScore()
                    }
                })
        })
    })

}
template.static.changeFileContent=function (){
    var fileContent = $('#template-static-select-file').val();
    if (fileContent.endsWith('.xls') || fileContent.endsWith('.xlsx')){
        $('#fileContent').html($('#template-static-select-file').val())
    }else {
        alert('请选择正确的excel文件')
    }
}
template.static.cancelSave=function (){
        if (!confirm('是否需要取消模板信息')){
            return;
        }
        $.post('template/cancelSave',null,function (){
           template.static.clearTemplate()
            alert('取消成功')
        })
}
template.static.clearTemplate=function (){
    $('#static_template_box #static_template_top_part .form-inline .form-group .form-control').val('')
    $('#static_template_left_content_box_inner_content').remove()
    template.static.computeRightScore()
}
template.static.templateSave=function (){
    var param={
        editTemplateId:$('#static_template_id').val()!=null?$('#static_template_id').val():'',
        name:$('#static_template_name').val(),
        course:$('#static_template_course').val(),
        type:'静态模板',
        question1_score:$('#static_template_question1_score').val(),
        question2_score:$('#static_template_question2_score').val(),
        question3_score:$('#static_template_question3_score').val(),
        question4_score:$('#static_template_question4_score').val(),
        question5_score:$('#static_template_question5_score').val(),
        question_total_score:$('#static_template_total_score span:eq(1)').html()
    }
    $.post('template/static/templateSave',param,function (f){
        if (!f){
            alert('模板名称重复')
        }else {
            alert('保存成功')
            template.static.clearTemplate()
        }
    })
}
<!--模板列表相关处理-->
template.list={}
template.list.query=function (page){
    var page = page!=null?page:1

    var param = {
        page:page,
        name:$('#name').val()!='==请选择=='?$('#name').val():'',
        course:$('#course').val()!='==请选择=='?$('#course').val():'',
        type:$('#type').val()!='==请选择=='?$('#type').val():'',
        status:$('#status').val()!='==请选择=='?$('#status').val():'',
        shareId:$('#share').val()!='==请选择=='?$('#share').val():'',
    }
   if ($('#exam_relation_template_symbol').val()!=undefined){
       param.examSymbol='examSymbol'
   }
   console.log(param)
    $.post('template/queryList.html',param,function (view){
        $('#template_list_body').html(view)
    })
}
template.list.clearQuery=function (){
    $('#template_list_head .form-inline .form-group .form-control').val('')
    template.list.query(1)
}
template.list.limitQueryS=function (page){
    template.list.query(page)
}
template.list.deleteOneList = function (id){
    if (confirm('是否删除模板')){
        $.post('template/list/deleteOne',{id:id},function (result){
            if (result){
                alert('删除成功')
                template.list.clearQuery()
            }else {
                alert('只能删除自己私有状态的模板并且未分享')
            }
        })
    }
}
template.list.editTemplateStatus=function (ev,self){
    //取消浏览器右键默认行为
    var event = ev || event;
    var positionX = event.clientX;
    var positionY = event.clientY;
    var templateId = $(self).parent().parent().children().eq(0).children().val()
    var div = $(`<div  onmouseleave="this.remove()">
                    <div><a href="javascript:void(0)" onclick="template.list.setPublicStatus(`+templateId+','+`this`+`)">设置公有</a></div>
                    <div><a href="javascript:void(0)" onclick="template.list.setAbandonStatus(`+templateId+','+`this`+`)">设置丢弃</a></div>
                    <div><a href="javascript:void(0)" onclick="template.list.setPrivateStatus(`+templateId+','+`this`+`)">设置私有</a></div>
                    <div><a href="javascript:void(0)" onclick="template.list.setShareStatus(`+templateId+','+`this`+`)">设置分享</a></div>
                </div>`);

    div.css({
        position:'absolute',
        paddingLeft:60,
        paddingTop:20,
        width:200,
        height:120,
        left:positionX,
        top:positionY,
        background:'#eee',
    });
    $('body').append(div);
    return false;
}
template.list.setPublicStatus = function (templateId,div){
    $.post('template/list/setStatus',{id:templateId,status:'公有'},function (result){
        if (result == 0){
            alert('只能修改自己的模板')
        }else if (result == 1){
            alert('修改成功')
            $(div).parent().parent().remove()
            template.list.clearQuery()
        }

    })
}
template.list.setPrivateStatus = function (templateId,div){
    $.post('template/list/setStatus',{id:templateId,status:'私有'},function (result){
        if (result == 0){
            alert('只能修改自己的模板')
        }else if (result == 1){
            alert('修改成功')
            $(div).parent().parent().remove()
            template.list.clearQuery()
        }

    })
}
template.list.setAbandonStatus = function (templateId,div) {
    $.post('template/list/setStatus', {id: templateId, status: '丢弃'}, function (result) {
        if (result == 0) {
            alert('只能修改自己的模板')
        } else if (result == 1) {
            alert('修改成功')
            $(div).parent().parent().remove()
            template.list.clearQuery()
        }

    })
}
template.list.setShareStatus = function (templateId, div) {
    //需要先获取到所有老师  因为跟老师模块差不多 所以 我们引用前面的视图
    $.post('template/list/shareTeacher.html', null, function (view) {
        common.commonModalDialogClearSubmitButtonBind()
        common.commonModalDialog('选择分享教师', view, function () {
            var shareTeacherIds = ''
            $('#common-modal #modal-dialog .modal-content .common-modal-body #template_list_body #teacherContextFragment .table tbody tr td input:checked').each(function (i, input) {
                shareTeacherIds += input.value + ','
            })
            if ($('#common-modal #modal-dialog .modal-content .common-modal-body #template_list_body #teacherContextFragment .table tbody tr td input:checked').length==0){
                alert('请选择分享的教师')
                return;
            }
            $.post('template/list/setShareStatus', {id: templateId, status: '分享', shareTeacherIds: shareTeacherIds},function (result){
                if (result == 0) {
                    alert('只能修改自己的模板')
                } else if (result == 1) {
                    alert('修改成功')
                    common.commonModalDialogClose()
                    $(div).parent().parent().remove()
                    template.list.clearQuery()
                }
            })
        })
    })
}
template.list.select = function () {
    var filterName = $('#filterName').val()
    $.post('template/list/select.html', {'filterName': filterName}, function (view) {
        common.commonModalContentChange(view)
    })
}
template.list.clearShareTeacherQuery = function () {
    $('#filterName').val('')
    $.post('template/list/clearShareTeacher.html', null, function (view) {
        common.commonModalContentChange(view)
    })
}
template.list.limitQuery = function (page) {
    var param = {}
    param.filterName = $('#filterName').val()
    param.page = page
    $.post('template/list/select.html', param, function (view) {
        common.commonModalContentChange(view)
    })
}
template.list.edit = function (templateId,templateTid,teacherId){
    // console.log(templateId+'---'+templateTid+'---'+teacherId)
    // console.log(typeof templateTid+'---'+typeof teacherId)
    // console.log(templateTid==teacherId)
    // return;
    if (templateTid!=teacherId){
        alert('只能修改自己的模板')
        return;
    }else{
        $.post('template/list/edit.html',{templateId:templateId},function (view){
           $('.context').html(view)
            template.dynamic.templateResolve()
            template.dynamic.scoreCompute()
            template.static.computeRightScore()
        })
    }
}


